home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
program
/
swagn_r.zip
/
RECORDS.SWG
/
0012_Finding Records.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-01-27
|
896b
|
30 lines
{
> What is the best way to Find a record in a file of Records?
> Can one seek to the specified record, or do you need to
> read each record in the file and check a field for the
> proper value?
If you want a search on one field, you better create a sorted index-file where
you can search on a btree-kind of way.
Something like this:
}
RecFile : Record =
Deleted: Boolean;
Name : String[15];
Descrip: String[25];
RText : Array[0..39] of String[82];
End;
IdxFile : Record =
Name : String[15]; {same as in RecFile}
Recnum : Word; {record.no. in RecFile}
End;
Var Rfile : File of RecFile;
Ifile : File of IdxFile;
{
If you keep your index-file sorted, you can search quikly for a name in the
index and a Seek(Rfile, Ifile.Recnum) gives you the record.
}